package com.headhunter.portlet.web;

import java.util.HashMap;
import java.util.Map;

import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.portlet.ModelAndView;
import org.springframework.web.portlet.mvc.AbstractController;

import com.headhunter.portlet.service.VocationService;

@Controller
public class ViewController extends AbstractController {

	@Autowired
	VocationService vocationService;

	protected ModelAndView handleRenderRequestInternal(RenderRequest request,
			RenderResponse response) throws Exception {
		Map<String, Object> map = new HashMap<String, Object>();
		if (vocationService == null) {
			System.out.println("service: null");
		} else {
			System.out.println("service: not null");
			
			map.put("vocationList", vocationService.vocationsListOrderByDate());
		   System.out.println("WORK " + vocationService.vocationsListOrderByDate());
		}
		ModelAndView modelAndView = new ModelAndView("view", map);
		return modelAndView;
	}

}
